package ThreadDemo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 阿宾
 * Date: 2025-03-17
 * Time: 09:46
 */
public class ThreadDemo8 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(
                () ->{
                    System.out.println("线程代码");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
        );

        //start开始之前，检查isAlive
        System.out.println("start开始之前:" + t.isAlive());
        t.start();
        System.out.println("start开始之后:" + t.isAlive());

        Thread.sleep(2000);
        System.out.println("t结束之后:" + t.isAlive());
    }
}
